﻿using CnControls;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.UI;

public class UIManager : MonoBehaviour {
    [Header("游戏画面的菜单按钮")]
    public Button main_menu_button;
    public Button main_exit_button;

    [Header("上面面板的几个按钮")]
    public Button top_person_button;
    public Button top_helper_button;
    public Button top_back_button;
    [Header("带移动摇杆的面板")]
    public GameObject touch_move_Panel;
    [Header("带顶部几个按钮的面板")]
    public GameObject top_button_ListPanel;
    [Header("人物显示面板上面的返回按钮")]
    public Button personListPanel_back_button;
    [Header("人物显示面板Panel")]
    public GameObject personListPanel;
    [Header("帮助面板上面的返回按钮")]
    public Button helpPanel_back_button;
    public GameObject helpPanel;

    // Use this for initialization
    void Start () {

        AddButtonClickListener();

    }
	
    void AddButtonClickListener ()
    {
        main_menu_button.onClick.AddListener(delegate () {
            this.Open_Top_Button_ListPanelPanel();
        });

        main_exit_button.onClick.AddListener(delegate () {
            SceneManager.LoadScene(0);
        });

        top_back_button.onClick.AddListener(delegate () {
            this.Open_TouchMovePanel();
        });

        top_person_button.onClick.AddListener(delegate () {
            this.Open_Person_ListPanelPanel();
        });

        top_helper_button.onClick.AddListener(delegate () {
            this.Open_Helper_PanelPanel();
        });

        personListPanel_back_button.onClick.AddListener(delegate () {
            this.Open_Top_Button_ListPanelPanel();
        });

        helpPanel_back_button.onClick.AddListener(delegate () {
            this.Open_Top_Button_ListPanelPanel();
        });

    }

    // Update is called once per frame
    void Update () {
       
	}

    public void CloseAllPanel()
    {
        Close_TouchMovePanel();
        Close_Top_Button_ListPanelPanel();
        Close_Helper_PanelPanel();
        Close_Person_ListPanelPanel();
    }

    private void Open_TouchMovePanel()
    {
        CloseAllPanel();
        //touch_move_Panel.SetActive(true);
        touch_move_Panel.GetComponent<EaseTools.EaseUI>().MoveIn();
    }

    private void Close_TouchMovePanel()
    {
        // touch_move_Panel.SetActive(false);
        touch_move_Panel.GetComponent<EaseTools.EaseUI>().MoveOut();
    }
    private void Open_Top_Button_ListPanelPanel()
    {
        CloseAllPanel();
        top_button_ListPanel.SetActive(true);
    }

    private void Close_Top_Button_ListPanelPanel()
    {
      
        top_button_ListPanel.SetActive(false);
    }

    private void Open_Helper_PanelPanel()
    {
        CloseAllPanel();
        helpPanel.SetActive(true);
    }

    private void Close_Helper_PanelPanel()
    {
        helpPanel.SetActive(false);
    }

    private void Open_Person_ListPanelPanel()
    {
        CloseAllPanel();
        personListPanel.SetActive(true);
    }

    private void Close_Person_ListPanelPanel()
    {
        personListPanel.SetActive(false);
    }

}
